package com.wcn.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class NumberUtils {
    //金额校验
    public boolean isNumber(String str) {
        // 判断小数点后2位的数字的正则表达式
        Pattern pattern = Pattern.compile("^(([1-9]{1}\\d*)|([0]{1}))(\\.(\\d){0,2})?$");
        Matcher match = pattern.matcher(str);
        if (match.matches() == false) {
            return false;
        }
        return true;
    }

    public static void main(String[] args) {
        NumberUtils numberUtils = new NumberUtils();
        System.out.println(numberUtils.isNumber("12"));
    }
}
